package cn.zhku.edu.productservice.controller;

import cn.zhku.edu.feign.common.R;
import cn.zhku.edu.productservice.service.ProductServies;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: clk
 * @Date:2021/9/13  15:49
 */

@CrossOrigin
@RestController
public class ProductController {

    @Autowired
    private ProductServies productServies;

    @RequestMapping("/detail")
    public R test(@RequestParam int gid){
        return new R(200,"访问成功！",productServies.getById(gid));
    }

    @RequestMapping("/product/getGoodsDetail")
    public R getProduct(@RequestParam int gid){
        return new R(200,"获取详情成功！",productServies.getDetailProductVO(gid));
    }

    @RequestMapping("/product/getIndexRecommendGoodsLists")
    public R getIndexRecommendGoodsLists(){
        int[] recomendedGoodsGids={2,3,4,5};
        return new R(200,"首页推荐栏获取成功",productServies.getIndexRecommendGoodsLists(recomendedGoodsGids));
    }
    @RequestMapping("/product/getIndexBrandsGoodsLists")
    public R getIndexBrandsGoodsLists(@RequestBody Map params){
        int aim= (int) params.get("count")-1;
        //0美特斯邦威 1oppo 2gukka 3华为 4九牧王
        String[] ImageArr = {
                "https://img14.360buyimg.com/babel/jfs/t1/159191/18/13713/44608/60517c4cE8653dac5/ef23165e47cc4da3.jpg",
                "https://img20.360buyimg.com/babel/jfs/t1/176147/10/21014/100556/60fa645aE5099d45e/744379608a2041d3.jpg",
                "https://img30.360buyimg.com/babel/jfs/t1/169132/30/12838/103058/60500cbcE12632888/0b4ab4d98f672a49.png",
                "https://img10.360buyimg.com/babel/jfs/t1/185959/29/13854/24587/60f0e73eE72f05498/86575a35d6c00359.jpg",
                "https://img13.360buyimg.com/babel/jfs/t1/163203/35/13264/181803/605019daEcfd098c8/abe4f31f39a9792f.jpg"
        };
        int[][] brandsGoodsGids={{5,6,7,8},{9,10,11,12},{13,14,15,16},{17,18,19,20},{21,22,23,24}};
        return new R(200,"首页旗舰栏获取成功", new Object[]{ImageArr[aim], productServies.getIndexRecommendGoodsLists(brandsGoodsGids[aim])});
    }
}
